<?php 

/**
 * 递归重组多维数组
 */
	function node_merge($node,$pid=0)
	{
		$arr = array();
		foreach ($node as $v) {
			if($v['id']==$pid){
				$v['child']  = node_merge($node,$v['pid']);
				$arr[] = $v;
			}
		}
		return $arr;
	}

/**
 * 设置分页
*/
	function page_str($count,$page,$listnum){
		$listnum = $listnum ? $listnum : 10;
		$currentpage = ($page->firstRow)/$listnum+1;
		if($count%$listnum>0)
			{
				$num = (int)($count/$listnum) +1;
			}else{
				$num = (int)($count/$listnum);
			}
		//>1说明有上一页
		$str = '<div class="panel-foot text-center">';
		if($currentpage>1)
		{
		$URL = U("Admin/Member/memberList",array("d" => 1 , "p" => $currentpage-1));
		$str .= '
			<ul class="pagination"><li>
			<a href="'.$URL.'">上一页</a></li></ul>
		';
		}
		$str .= '<ul class="pagination pagination-group">';
		for($i=0;$i<$num;$i++)
			{
				$str .= '<li';
				if(($page->firstRow/$listnum)==$i)
					{$str .= ' class="active">';}
				else
					{$str .='>';}
				$URL = U('Admin/Member/memberList',array( "d" => 1,'p'=> $i+1));
				$str .= '<a href="'.$URL.'">';
				$str .= ($i+1).'</a>';
				$str .= '</li>';
			}
		$str .= ' </ul>';
		//同样设置下一页
		if($currentpage<$num)
		{
		$URL = U("Admin/Member/memberList",array("d" => 1,"p" => $currentpage+1));
		$str .= '
			<ul class="pagination"><li>
			<a href="'.$URL.'">下一页</a></li></ul>
		';
		}
		$str .= '</div>';
		return $str;
	}
 ?>